#ifndef __BH1750_H__
#define __BH1750_H__
    #include <stdio.h>
    #include <unistd.h>
    #include <stdbool.h>
	#include <stdio.h>
	#include <stdint.h>
	#include "ohos_init.h"
	#include "cmsis_os2.h"
	#include "iot_gpio.h"
	#include "iot_gpio_ex.h"
	#include "iot_i2c.h"
	#include "iot_i2c_ex.h"

    //从设备地址
	#define BH1750_DEVICE_ADDRESS		0x23

	/*****	指令集宏定义  *****/
	#define	BH1750_POWER_OFF			0x00	//断电指令
	#define	BH1750_POWER_ON				0x01	//通电,等待测量命令
	#define	BH1750_MODULE_RESET			0x07	//重置数据寄存器，关机模式下，不能接受重置命令

	/*****	工作模式指令集  *****/
	#define	BH1750_CONTINUE_H_MODE1		0x10	//连续H分辨率模式1
	#define	BH1750_CONTINUE_H_MODE2		0x11	//连续H分辨率模式2
	#define	BH1750_CONTINUE_L_MODE		0x13	//连续L分辨率模式
	#define	BH1750_ONE_TIME_H_MODE1		0x20	//一次H分辨率模式1
	#define	BH1750_ONE_TIME_H_MODE2		0x21	//一次H分辨率模式2
	#define	BH1750_ONE_TIME_L_MODE		0x23	//一次L分辨率模式
	
	#define BH1750_CONTINUE_MODE		BH1750_CONTINUE_H_MODE2

	//分辨率	光照强度（单位lx）=（High Byte  + Low Byte）/ 1.2 * 测量精度
	#if ((BH1750_CONTINUE_MODE==BH1750_CONTINUE_H_MODE2)|(BH1750_CONTINUE_MODE==BH1750_ONE_TIME_H_MODE2))
		#define RESOLURTION		0.5
	#elif ((BH1750_CONTINUE_MODE==BH1750_CONTINUE_H_MODE1)|(BH1750_CONTINUE_MODE==BH1750_ONE_TIME_H_MODE1))
		#define RESOLURTION		1
	#elif ((BH1750_CONTINUE_MODE==BH1750_CONTINUE_L_MODE)|(BH1750_CONTINUE_MODE==BH1750_ONE_TIME_L_MODE))
		#define RESOLURTION		4
	#endif	


	bool BH1750_Init(void);

	bool BH1750_GetData(float *lightIntensity);
#endif /* __BH1750_H__ */
